package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
//import com.example.model.BeerExpert;
/*
Trouble shooting: compile error: package com.example.model not exist

Solving: -cp . src\com\example\model\*.java
D:\JAVASEVERLETJSP\beerV1>javac -cp . src\com\example\model\*.java -classpath D:
\tomcat\lib\servlet-api.jar;classes:. -d classes src\com\example\web\BeerSelect.java
*/
public class BeerSelect extends HttpServlet {

	public void doPost(HttpServletRequest request,
				HttpServletResponse response) throws
				IOException, ServletException {
//		response.setContentType("text/html");
//		PrintWriter out = response.getWriter();
		String c = request.getParameter("color");
//		out.println("Beer Selection Advice <br>");		
//		out.println("<br> Got beer color HieuMT " + c);		
		
		BeerExpert ob = new BeerExpert();
		List<String> listFromExpert = (List)ob.getBrands(c);
//		out.println("The Beer Expert advice <br>");
//		for(int index = 0; index < listFromExpert.size(); index++) {
//			out.println(listFromExpert.get(index)+"<br>");
//		}
		request.setAttribute("styles", listFromExpert);
		RequestDispatcher view = request.getRequestDispatcher("result.jsp");
		view.forward(request, response);
	}
}

